home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-01 | 6.5 KB | 126 lines | [TEXT/KAHL] |
- ******************************************************
- ******************************************************
-
- KNOWN BUGS in Mac F2C v1.1
-
- ******************************************************
- ******************************************************
-
- There are several known problems with Mac F2C. There is one known code
- generation problem, but it is relatively minor and easy to work around.
- The more serious problems are all related to Mac F2C's user interface and
- memory leaks. These problems come from one of two sources: the use of the
- THINK C console library, and the incorporation of the UNIX version of f2c
- as a subroutine in Mac F2C.
-
-
-
- Code Generation Problems
- *********************************************
-
- There is one code generation problem that I know of.
-
- - Unlabeled COMMON blocks defined in separate C files and
- declared Extern
-
- This problem occurs when the program contains an unlabeled COMMON
- block and you have selected the options to define the COMMON block in
- a separate file and declare the block "Extern" in the original file
- (the factory default behavior). In this case the C version of the
- original FORTRAN file will #define a symbolic constant to refer to
- the COMMON block (which is translated as a struct). The error is
- that f2c will include an #undef statement after the end of the first
- subroutine in the file -- even if subsequent subroutines refer to that
- symbol. This produces a preprocessor error when you try to compile
- the C file (e.g., "Symbol '_BLNK__1' is undefined").
-
- There are two work-arounds for this bug:
-
- (a) Do not select the options that define COMMON blocks in separate
- files and define them Extern. Unfortunately, this will not always
- work: multiple definition errors will occur in the C code when the
- same COMMON block is used in separate files of FORTRAN code.
-
- (b) Go through the C code and delete the spurious #undef lines.
- This is usually easy to do and is the recommended solution. The
- disadvantage is that this is hard to script if you use a scripting
- tool of any kind to drive the builds of your FORTRAN code.
-
-
-
- Problems related to the THINK console library
- *********************************************
-
- The f2c kernel uses standard I/O calls (fprintf(), fputs(), etc) to display
- status message. Mac F2C uses the THINK C console library to display these
- messages in a Macintosh ‘status’ window. Unfortunately, the THINK C
- console library has some undesirable "features" and side effects. The ones
- I know of are:
-
- - The ‘Edit’ menu ‘Cut’, ‘Paste’, and ‘Clear’ commands do not work on
- the Mac F2C status window. The ‘Copy’ command DOES work.
-
- - The Mac F2C status window cannot be scrolled.
-
- - Command-key combinations for commands that are not on the ‘Edit’
- menu (e.g., Cmd-Q for Quit, Cmd-O, for Open/Translate) do not work
- if the Mac F2C status window is the front window.
-
- There are probably others I have forgotten or don't know about. My long
- term solution is to write my own code to catch the standard I/O calls and
- send them to a full-featured, scrollable status window of my own design
- that you will be able to save to a text file. Although the window itself
- is easy to put together, plugging into the standard I/O mechanism is hard
- because f2c also uses the standard I/O library to read/write from disk. I
- need to either (a) sift out only those writes to stdout and stderr without
- breaking the other ones, or (b) grab all of them and handle both screen I/O
- and file I/O myself. Either way, it's more work than I have the time to
- take on right now. This item is saved for version 2.0...
-
-
-
- Problems related to the f2c kernel
- *********************************************
-
- There are a series of problems that arise because the original UNIX version
- of f2c (a stand-alone program) is incorporated in Mac F2C as a subroutine.
- The original UNIX f2c is designed to compile one file and quit, so lots of
- bugs such as memory leaks and dangling open files don't show up -- all
- memory is released and files are automatically closed when the program
- quits. In Mac F2C, the original f2c program has been turned into a
- subroutine which can be called several times -- and each time the leaked
- memory is lost to future iterations. I have fixed the dangling open file
- bugs in f2c, but not the memory leaks. This means that you can easily run
- out of memory if you translate more than about a dozen FORTRAN files at a
- shot (fewer if they are big or complicated). The work-around is to
- translate a few files at a time, quit and re-start Mac F2C, and then do a
- few more. You can also give Mac F2C a bigger memory allocation.
-
- I have received numerous suggestions for fixing the memory leak problem.
- They've ranged from implementing my own memory management functions (one
- user kindly provided code to do this), to creating a new heap zone for f2c
- and blowing the whole zone away when f2c finished. Unfortunately, tracking
- down the memory and freeing it is not the problem. The real problem is
- that f2c keeps pointers -- many dozens of them -- to that memory. If I
- just blow that memory away, I'm left with lots and lots of dangling
- pointers. Some pointers would be easy to re-initialize: they are declared
- as global variables. All I need to do is write a function that declares
- these variables as extern and set all of them to NULL. But many other
- variables are declared as static local variables -- I can't get at them in
- one of my own functions. To be able to re-initialize these I need to
- modify the f2c code. I can't do this without an extensive re-write of the
- f2c code (just changing them from local static variables to global
- variables doesn't work because many of these local variables have the same
- name). And I _really_ don't want to do an extensive re-write of the f2c
- code because (a) I'm lazy, and (b) it would become very _painful_ to update
- Mac F2C to newer versions of f2c. Keeping Mac F2C reasonably current
- vis-a-vis UNIX f2c has always been one of my primary goals, so I'm loath to
- sacrifice that goal to fix the memory problem.
-
- The bottom line is that although I know how I could do it, don't expect the
- memory leaks to be fixed in the near future. What do you -- my users --
- think is more important: fixing the memory leaks or keeping Mac F2C current
- with UNIX f2c? Let me know at igormt@alumni.caltech.edu.
-
-
-